package com.blkbox.javaee.quartz.version2_0;

import java.util.ArrayList;
import java.util.Date;

import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;

public class SimpleQuartzJob implements Job {

	public SimpleQuartzJob() {
	}

	public void execute(JobExecutionContext context) throws JobExecutionException {
		System.out.println("SimpleQuartzJob - Executed at time: " + new Date() + ", by Trigger: " + context.getTrigger().getKey());

		JobKey key = context.getJobDetail().getKey();
//		JobDataMap dataMap = context.getJobDetail().getJobDataMap();
		JobDataMap dataMap = context.getMergedJobDataMap();
		String name = dataMap.getString("name");
		String password = dataMap.getString("password");
		Date date = (Date) dataMap.get("date");
		ArrayList list = (ArrayList) dataMap.get("list");
		System.out.println("JobKey " + key + " of names: " + name + ", and date is: " + date+ ", and list size is: " + list.size());
		list.add("a");
	}
}
